﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BSPortal;

namespace BSPortal.Usercontrol
{
    public partial class Contact : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            if (txtCapcha.Text != System.Web.HttpContext.Current.Session[PageConst.CapchaName].ToString())
            {
                Response.Write("<script>alert('Mã xác nhận không chính xác!')</script>");
                return;
            }

            string title = "Email contact from " + txtName.Text;
            string content = "<strong>Name:</strong> " + txtName.Text + "<br>";
            content += "<strong>Phone:</strong> " + txtEmail.Text + "<br>";
            content += "<strong>Phone:</strong> " + txtPhone.Text + "<br>";
            content += "<strong>Phone:</strong> " + txtAddress.Text + "<br>";
            content += "<strong>Content:</strong> " + txtContent.Text + "<br>";
            if (Common.Sendmail(Common.GetValueInAppSetting("sendemail","hotro_72h@yahoo.com"), title, content))
            {
                txtName.Text = "";
                txtEmail.Text = "";
                txtPhone.Text = "";
                txtContent.Text = "";
                txtAddress.Text = "";
                txtCapcha.Text = "";
                Response.Write("<script>alert('Gữi thành công!')</script>");
                Response.Redirect("trangchu.html");
            }
            else
            {
                Response.Write("<script>alert('Gữi không thành công!')</script>");
            }
        }
    }
}